﻿using System.Collections.Generic;

namespace GameFramework.Battle.Core
{
    public static class AnimationTypeHelper
    {
        private static int index = 0;
        private static Dictionary<string, int> animationNameToIndexMap = new Dictionary<string, int>();
        private static List<string> animationNameList = new List<string>();

        public static bool GenerateEnumOnFinish;
        public static string NamespaceOfGeneratedEnum;
        public static string NameOfGeneratedEnum;
        public static string PathOfGeneratedEnum;

        public static int GetAnimationTypeIndex(string animationName)
        {
            if (string.IsNullOrEmpty(animationName))
            {
                UnityEngine.Debug.LogErrorFormat("animationName IsNullOrEmpty");
                return -1;
            }

            animationName = animationName.Replace(" ", "_");

            if (animationNameToIndexMap.TryGetValue(animationName, out int i))
            {
                return i;
            }

            animationNameList.Add(animationName);
            animationNameToIndexMap[animationName] = index;
            UnityEngine.Debug.LogFormat("Add Animations [{0}] = {1}", index, animationName);
            int ii = index;
            index++;
            return ii;
        }

    }
}
